package com.phoneSort;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.WritableComparable;

public class PhoneBean implements WritableComparable<PhoneBean>{


    private String phoneNumber;//电话号码
    private Long knockout;
    private Long infiltrate;
    private Long sum;

    public String getPhoneNumber() {
        return phoneNumber;
    }
    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public Long getKnockout() {
        return knockout;
    }

    public void setKnockout(Long knockout) {
        this.knockout = knockout;
    }

    public Long getInfiltrate() {
        return infiltrate;
    }

    public void setInfiltrate(Long infiltrate) {
        this.infiltrate = infiltrate;
    }

    public Long getSum() {
        return sum;
    }

    public void setSum(Long sum) {
        this.sum = sum;
    }

    public PhoneBean(String phoneNumber, Long knockout, Long infiltrate) {
        this.phoneNumber = phoneNumber;
        this.knockout = knockout;
        this.infiltrate = infiltrate;
        this.sum = knockout + infiltrate;
    }
    public PhoneBean() {
    }

    @Override
    public String toString() {
        return "PhoneBean{" +
                "phoneNumber='" + phoneNumber + '\'' +
                ", knockout=" + knockout +
                ", infiltrate=" + infiltrate +
                ", sum=" + sum +
                '}';
    }
    public void readFields(DataInput in) throws IOException {
        phoneNumber = in.readUTF();
        knockout = in.readLong();
        infiltrate = in.readLong();
        sum = in.readLong();

    }
    public void write(DataOutput out) throws IOException {
        out.writeUTF(phoneNumber);
        out.writeLong(knockout);
        out.writeLong(infiltrate);
        out.writeLong(sum);
    }
    public int compareTo(PhoneBean o) {
        return sum > o.sum ? -1 : 1;
    }
}